#!/bin/bash

# This script creates 3 users with various roles.
# These users are seeded to Fleet Free E2E tests

source $FLEET_ENV_PATH

# Create users
create_user_endpoint="api/latest/fleet/users/admin"

# Create Anna
data='{
  "name": "Anna",
  "email": "anna@organization.com",
  "password": "password123#",
  "invited_by": 1,
  "global_role": "admin",
  "admin_forced_password_reset": false
}'
curl -X POST $CURL_FLAGS -H "Authorization: Bearer $TOKEN" "$SERVER_URL/$create_user_endpoint" -d "$data" --insecure

# Create Mary
data='{
  "name": "Mary",
  "email": "mary@organization.com",
  "password": "password123#",
  "invited_by": 1,
  "global_role": "maintainer",
  "admin_forced_password_reset": false
}'
curl -X POST $CURL_FLAGS -H "Authorization: Bearer $TOKEN" "$SERVER_URL/$create_user_endpoint" -d "$data" --insecure

# Create Oliver
data='{
  "name": "Oliver",
  "email": "oliver@organization.com",
  "password": "password123#",
  "invited_by": 1,
  "global_role": "observer",
  "admin_forced_password_reset": false
}'
curl -X POST $CURL_FLAGS -H "Authorization: Bearer $TOKEN" "$SERVER_URL/$create_user_endpoint" -d "$data" --insecure
